#include <windows.h>
#include <windowsx.h>

#include "myWindow\myWindow.h"
#include "myD3D\myD3D.h"

#define window true
#define scr_w 640
#define scr_h 480

int WINAPI WinMain(HINSTANCE hInst, HINSTANCE, LPSTR, int){

	// create variables for window and directX
	myWindow myWnd;
	myD3D md3d;

	// init window
	if (!myWnd.myCreateWindow(hInst, L"DX SkinnedMesh...", !window, scr_w, scr_h))
		return 10;

	// init directX
	if (!md3d.Init(myWnd.getWndHandle(), !window, scr_w, scr_h))
		return 20;

	// load .x file with skinned mesh
	if (FAILED(md3d.loadSkin(L"x_files\\mate.x")))
		return 30;

	//if (FAILED(md3d.loadSkin(L"x_files\\tBone.x")))
	//	return 30;

	// enter an infinite message loop
	MSG msg;
	while (true){
		if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)){
			if(WM_QUIT == msg.message)
				break;
			TranslateMessage(&msg);
			DispatchMessage(&msg);
		}

		// TO DO: Render here
		md3d.RenderFrame();
	}

	return msg.wParam;
}